#pragma once

#include <string>
#include <iostream>
#include <GL\glui.h>
#include "View.h"

using namespace std;

class Perspective: public View
{
private:
	float near, far, angle;
	float fromX, fromY, fromZ;
	float toX, toY, toZ;
public:
	Perspective() {}
	void setFirst(float n, float f, float a)
	{
		near = n;
		far = f;
		angle = a;
	}
	void setSecond(float fX, float fY, float fZ)
	{
		fromX = fX;
		fromY = fY;
		fromZ = fZ;
	}
	void setThird(float tX, float tY, float tZ)
	{
		toX = tX;
		toY = tY;
		toZ = tZ;
	}
	void applyView() 
	{
		extern float xy_aspect;

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glMatrixMode( GL_PROJECTION );
        glLoadIdentity();
        gluPerspective(angle, xy_aspect, near,far);
        glMatrixMode( GL_MODELVIEW );
        glLoadIdentity();
        if(toX==fromX && toZ==fromZ)
                gluLookAt(fromX,fromY,fromZ,toX,toY,toZ,1,0,0);
        else
                gluLookAt(fromX,fromY,fromZ,toX,toY,toZ,0,1,0);

	}
};